<?php

use think\facade\Route;

//首页
Route::get('index', 'app\controller\index\Index@index');
Route::miss(function () {
    return redirect('index');
});
// API 路由分组
Route::group('api', function () {

    Route::group('wap', function () {
        Route::get('check', 'app\controller\index\Index@wap');//版本落地页
        Route::get('detail', 'app\controller\index\Agreement@info');
    });


    //更新版本检测
    Route::get('update', 'app\controller\index\Update@check');
    Route::get('web_version', 'app\controller\index\Update@web_version');//web端版本

    //升级包
    Route::group('wgt', function () {
        Route::post('check', 'app\controller\index\Update@wgt_version');//检查更新
    });


    // 协议
    Route::group('agreement', function () {
        Route::get('register', 'app\controller\index\Agreement@register');// 注册协议
        Route::get('privacy', 'app\controller\index\Agreement@privacy');// 隐私政策
        Route::get('about', 'app\controller\index\Agreement@about');// 关于我们
    });

    //更新日志
    Route::get('update-log', 'app\controller\index\Update@update_log');

    //图形验证码
    Route::get('captcha', 'app\controller\index\Captcha@get');
    Route::post('login', 'app\controller\index\User@login');//密码登录
    //微信小程序登录
    Route::post('code_login', 'app\controller\index\User@code_login');

    Route::post('register', 'app\controller\index\User@reg'); // 创建新用户

    Route::get('me', 'app\controller\index\User@info');//用户信息
    Route::put('profile', 'app\controller\index\User@update');//更新用户信息
    Route::put('updateAccount', 'app\controller\index\User@update_account');//更新登录账号
    Route::put('updatePwd', 'app\controller\index\User@update_password');//更新密码
    Route::get('push_setting', 'app\controller\index\User@push_setting');//推送设置
    Route::put('push_setting', 'app\controller\index\User@push_setting');
    Route::put('update-email', 'app\controller\index\User@update_email');//更新邮箱
    Route::get('account-list', 'app\controller\index\User@account_list');//关联的账号列表
    Route::post('bind-account', 'app\controller\index\User@account_bind');//关联的账号
    Route::post('switch-account', 'app\controller\index\User@account_switch');//关联的账号-切换
    Route::post('unbind-account', 'app\controller\index\User@account_unbind');//关联的账号-解绑
    Route::post('cancel-account', 'app\controller\index\User@account_cancel');//注销
    Route::post('regret-cancel', 'app\controller\index\User@regret_cancel');//注销-撤回
    Route::post('user/forget_pwd', 'app\controller\index\User@forget_pwd');//找回密码


    Route::get('category/info/:id', 'app\controller\index\Category@get');//分类
    Route::get('category/list', 'app\controller\index\Category@list');//分类
    Route::post('category', 'app\controller\index\Category@action');//分类
    Route::put('category', 'app\controller\index\Category@action');//分类
    Route::delete('category/:id', 'app\controller\index\Category@delete');//分类


    Route::get('cashflow-list', 'app\controller\index\Cashflow@list');//记账列表，合并
    Route::get('cashflow-list-all', 'app\controller\index\Cashflow@list_all');//记账列表
    Route::get('cashflow-list-search', 'app\controller\index\Cashflow@list_all_search_params');//搜索条件
    Route::post('cashflow', 'app\controller\index\Cashflow@add');//新增记账
    Route::get('cashflow/:id', 'app\controller\index\Cashflow@get');//获取详情
    Route::delete('cashflow/:id', 'app\controller\index\Cashflow@delete');//删除
    Route::put('cashflow', 'app\controller\index\Cashflow@update');//修改账单
    Route::get('cashflow-pre', 'app\controller\index\Cashflow@ready');//预设数据
    Route::get('cashflow-export', 'app\controller\index\Cashflow@export');//导出
    Route::post('cashflow-import-file', 'app\controller\index\Cashflow@import_file');//导入解析文件
    Route::post('cashflow-import', 'app\controller\index\Cashflow@import');//导入
    Route::get('cashflow-import-tpl', 'app\controller\index\Cashflow@import_tpl');//导入模板
    Route::post('cashflow-display', 'app\controller\index\Cashflow@set_display');//隐私设置

    Route::get('notifications', 'app\controller\index\Msg@list');//消息
    Route::get('notification/:msg_id', 'app\controller\index\Msg@get');//消息-详情
    Route::get('notification-read-all', 'app\controller\index\Msg@read_all');


    //统计
    Route::group('statistic', function () {
        Route::get('type', 'app\controller\index\Statistic@type');
        Route::get('setting', 'app\controller\index\Statistic@setting_get');
        Route::put('setting', 'app\controller\index\Statistic@setting_set');
        Route::get('table_list', 'app\controller\index\Statistic@table_list');
        Route::get('calendar', 'app\controller\index\Statistic@calendar');
    });


    //上传相关
    Route::group('upload', function () {
        Route::rule('image', 'app\controller\index\Upload@image');//图片上传
    });

    //留言反馈
    Route::post('feedback', 'app\controller\index\User@feedback');
    Route::get('feedback-list', 'app\controller\index\User@feedback_list');

    //邮箱验证码
    Route::group('code', function () {
        Route::get('send', 'app\controller\index\Code@send_code');//发送验证码
        Route::rule('find_pwd', 'app\controller\index\Code@find_pwd', 'POST|GET');//发送验证码
    });

    //预算
    Route::group('budget', function () {
        Route::get('list', 'app\controller\index\Budget@list');//预算列表
        Route::post('add', 'app\controller\index\Budget@add');//预算新增
        Route::put('update', 'app\controller\index\Budget@update');//预算修改
        Route::delete('delete', 'app\controller\index\Budget@delete');//预算删除
        Route::get('detail', 'app\controller\index\Budget@get');//预算详情
    });

    //帮助
    Route::group('help', function () {
        Route::get('list', 'app\controller\index\Help@list');
    });

    Route::get('icon-list', 'app\controller\index\Category@icon_list');

    //公告列表
    Route::get('notice-list', 'app\controller\index\Msg@notice_list');

    //收支类型
    Route::group('amount_type', function () {
        Route::get('list', 'app\controller\index\AmountType@list');
        Route::get('detail', 'app\controller\index\AmountType@get');
        Route::rule('save', 'app\controller\index\AmountType@save', 'PUT|POST');
        Route::delete('remove', 'app\controller\index\AmountType@delete');
    });


    //扩展插件
    Route::group('extend', function () {
        Route::get('list', 'app\controller\index\Extend@list');
        Route::get('detail', 'app\controller\index\Extend@get');
        Route::post('save', 'app\controller\index\Extend@save');
        Route::delete('remove', 'app\controller\index\Extend@delete');
        Route::get('my_list', 'app\controller\index\Extend@my_list');
        //妙想屋
        Route::group('idea', function () {
            Route::get('list', 'app\controller\index\PluginIdea@list');
            Route::get('detail', 'app\controller\index\PluginIdea@get');
            Route::rule('save', 'app\controller\index\PluginIdea@save', 'PUT|POST');
            Route::delete('remove', 'app\controller\index\PluginIdea@delete');
        });

        //妙想屋
        Route::group('cashbook', function () {
            Route::get('list', 'app\controller\index\PluginCashbook@list');
            Route::get('detail', 'app\controller\index\PluginCashbook@get');
            Route::rule('save', 'app\controller\index\PluginCashbook@save', 'PUT|POST');
            Route::delete('remove', 'app\controller\index\PluginCashbook@delete');
            Route::get('fetch', 'app\controller\index\PluginCashbook@fetch');
            Route::post('join', 'app\controller\index\PluginCashbook@join');
            Route::get('user_list', 'app\controller\index\PluginCashbook@user_list');
            Route::delete('unbind_user', 'app\controller\index\PluginCashbook@unbind_user');
        });
    });

    //设置
    Route::group('setting', function () {
        Route::get('base_info', 'app\controller\index\Setting@base_info');//基础信息
        Route::put('update', 'app\controller\index\Setting@update');//修改
        Route::get('detail/:key', 'app\controller\index\Setting@get');//详情
    });
});




